/**********************************************************************************
 * Copyright (c) 2012 - 2012,  quick_tools, All right reserved
 * Title:   TestRegex.java 
 * @author shen  shenqiao2012@163.com 
 *  2012-7-24 下午4:36:09 
 *********************************************************************************/

public class TestRegex {
	private final static String regPrintOut="String[%s] matches REGEX[%s] : Result[%b]";

	/**
	 * Description: 这里用一句话描述这个方法的作用 
	 * author:  shen
	 * @param args 
	 * @return void
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		testRegex();
	}
	
	public static void testRegex() {
		String str1="中文字符chinese";
		System.out.println("String["+str1+"]:\tLength=["+str1.length()+"]\tCharArrayLength=["+str1.toCharArray().length+"]");
		String str2="12333334";
		String str3="1中zheshiyige未知的4";
		String str4="1sdfjiesdfper4";
		String reg1="\\d{8}";
		String reg2="1.*4";
		String reg3="1\\S*4";
		String reg4="1\\S{5,20}4";
		String str5="CMDP_CMD_DSTR_DCM_PRE_ACHN_L88_PB_20120000000000_YEAR_1.PNG";
		String str5_1="CMDP_CMD_DSTR_DCM_PRE_ACHN_L88_PB_20120056123400_YEAR_1.PNG";
		String str5_2="CMDP_CMD_DSTR_DCM_PRE_ACHN_L88_PB_20120044sdfe00_YEAR_1.PNG";
		String str5_3="CMDP_CMD_DSTR_DCM_PRE_ACHN_L88_PB_201200asabcde00_YEAR_1.PNG";
		String reg5="CMDP_CMD_DSTR_DCM_PRE_ACHN_L88_PB_201200\\S{6}00_YEAR_1.PNG";
		String reg6="CMDP_CMD_DSTR_\\S*_PB_201200\\S{6}00_YEAR_1.PNG";
		String str6="CMDP_CMD_DSTRase_PB_20120000000000_YEAR_1.PNG";
		String str6_1="CMDP_CMD_DSTR_123中文这是什么情况_L88_PB_20120000000000_YEAR_1.PNG";
		String str6_2="CMDP_CMD_DSTR_bbcPB_20120000000000_YEAR_1.PNG";
		String str7="CMDP_CMD_DSTR_DCM_PRE_ACHN_L88_PB_20120000000000_YEAR_1 - 副本 - 副本.PNG";
		String reg7="CMDP_CMD_DSTR_\\S{4}PRE_ACHN_L88_\\S{2}_(\\S|\\s)*.PNG";
		System.out.println(String.format(regPrintOut, str2,reg1,str2.matches(reg1)));
		System.out.println(String.format(regPrintOut, str2,reg2,str2.matches(reg2)));
		System.out.println(String.format(regPrintOut, str2,reg3,str2.matches(reg3)));
		System.out.println(String.format(regPrintOut, str3,reg3,str3.matches(reg3)));
		System.out.println(String.format(regPrintOut, str3,reg4,str3.matches(reg4)));
		System.out.println(String.format(regPrintOut, str4,reg4,str4.matches(reg4)));
		System.out.println(String.format(regPrintOut, str5,reg5,str5.matches(reg5)));
		System.out.println(String.format(regPrintOut, str5_1,reg5,str5_1.matches(reg5)));
		System.out.println(String.format(regPrintOut, str5_2,reg5,str5_2.matches(reg5)));
		System.out.println(String.format(regPrintOut, str5_3,reg5,str5_3.matches(reg5)));
		System.out.println(String.format(regPrintOut, str5,reg6,str5.matches(reg6)));
		System.out.println(String.format(regPrintOut, str6,reg6,str6.matches(reg6)));
		System.out.println(String.format(regPrintOut, str6_1,reg6,str6_1.matches(reg6)));
		System.out.println(String.format(regPrintOut, str6_2,reg6,str6_2.matches(reg6)));
		System.out.println(String.format(regPrintOut, str7,reg7,str7.matches(reg7)));
	}

}
